<?php
/**
* socket test
socket live：
socket_create > socket_bind address and port > listen or connect
*/
//socket server
$buffer = 'test2';
$socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
socket_bind($socket,'192.168.3.222');
socket_connect($socket, '192.168.3.222',5000);

socket_write($socket, $buffer);
while($buf = socket_read($socket, 2048)){
	echo $buf.';';
	sleep(1);
	socket_write($socket, $buffer);
}
socket_close($socket);